import { MAP_CONFIG } from './config.js'

function deleteFeature({ fids, layerIndex, layer }) {
  //选择点所在的地图文档
  const deleteService = new Zondy.Service.EditDocFeature(
    MAP_CONFIG.docName,
    layerIndex,
    {
      ip: MAP_CONFIG.ip,
      port: MAP_CONFIG.port,
    }
  )
  deleteService.deletes(fids, (data) => {
    onDeleteSuccess(data, layer)
  })
}

function onDeleteSuccess(data, layer) {
  if (data.succeed) {
    alert('删除成功！')
    layer.refresh()
  } else {
    alert('删除失败！')
  }
}

export default deleteFeature
